package srcInterviewPrep;

public final class SubsequenceMatching
{
    public static boolean IsSubsequence(char[] str1, char[] str2)
    {
        int pos1 = 0;
        int pos2 = 0;
        
        while (pos1 < str1.length && pos2 < str2.length)
        {
            if (str1[pos1] == str2[pos2])
            {
                ++pos1;
                ++pos2;
            }
            else
            {
                ++pos1;
            }
        }
        
        if (pos2 < str2.length)
        {
            return false;
        }
        
        return true;
    }
}
